package com.world.rickcloudendpoint.algorithm;

import com.alibaba.fastjson.JSONArray;

import java.util.List;

/**
 * @description:
 * @author: jlsong
 * @date: 2021/12/27 23:06:48
 * @version: 1.0
 */
public class MainRunner {

    public JSONArray calculate(String startPos, String endPos) throws Exception {

        Point startPoint = Point.FromString(startPos, ",");
        Point endPoint = Point.FromString(endPos, ",");

        //获取导航数据
        Navigation nav = new Navigation();
        List<Point> resultPoints = nav.doNav(startPoint, endPoint);
        JSONArray array = new JSONArray();
        array.add(startPoint);
        for (int i = resultPoints.size() - 1; i >= 0; i--) {
            array.add(resultPoints.get(i));
        }
        array.add(endPoint);
        return array;
    }

    public static void main(String[] args) {
        String startPos = "119.701984,38.068558,1000";
        String endPos = "120.111324,39.32289,1000";
        MainRunner runner = new MainRunner();
        try {
            JSONArray ret = runner.calculate(startPos, endPos);
            System.out.println(ret.toJSONString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
